<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:with="title='sys_job'">
<meta charset="utf-8">
<header th:replace="header::headerFragment(${title})"></header>
<body class="gray-bg">
	<div class="wrapper wrapper-content ">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
						<form class="form-horizontal m-t" id="JobForm">
							<input id="jobId" name="jobId" th:value="${job.jobId}" type="hidden"> <input id="oldJobName" name="oldJobName"
								th:value="${job.oldJobName}" type="hidden"> <input id="oldJobGroup" name="oldJobGroup" th:value="${job.oldJobGroup}"
								type="hidden">
							<div class="form-group">
								<label class="col-sm-3 control-label">任务名称：</label>
								<div class="col-sm-8">
									<input id="jobName" name="jobName" th:value="${job.jobName}" class="form-control" readonly="readonly" type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">任务组名：</label>
								<div class="col-sm-8">
									<input id="jobGroup" name="jobGroup" th:value="${job.jobGroup}" class="form-control" readonly="readonly" type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">任务方法：</label>
								<div class="col-sm-8">
									<input id="jobClassName" name="jobClassName" th:value="${job.jobClassName}" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">任务描述：</label>
								<div class="col-sm-8">
									<input id="description" name=description th:value="${job.description}" class="form-control" type="text">
								</div>
							</div>
<!-- 							<div class="form-group" hidden=""> -->
<!-- 								<label class="col-sm-3 control-label">方法参数：</label> -->
<!-- 								<div class="col-sm-8"> -->
<!-- 									<input id="methodParams" name="methodParams" th:value="${job.methodParams}" class="form-control" readonly="readonly" type="text"> -->
<!-- 								</div> -->
<!-- 							</div> -->
							<div class="form-group" hidden="">
								<label class="col-sm-3 control-label">cron执行表达式说明：</label>
								<div class="col-sm-8">
									<input id="cronDesc" name="cronDesc" readonly="readonly" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">cron执行表达式：</label>
								<div class="col-sm-8">
									<input id="cronExpression" name="cronExpression" th:value="${job.cronExpression}" class="form-control" type="text"> <span
										class="help-block m-b-none"><i class="fa fa-info-circle"></i> <b>说明：设置定时器调度的时程表格式</b> <br> <b>秒</b>(0-59,*) <b>分</b>(0-59,*)
										<b>时</b>(0-23,*) <b>日</b>(0-31,*,?) <b>月</b>(0-11) <b>周</b>(1-7,*,? 1=SUN) /指数值的增量 
										<br>示例①<code> 0 0 12 * * ? </code>  &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;每月每日12时0分0秒
										<br>示例②<code> 0 15,16 10 15 * ?</code>  &nbsp;&nbsp;每月15日10时15,16分0秒
										<br>示例③<code> 0 15 10 ? * 2-6 </code>&nbsp;&nbsp;&nbsp;&nbsp;每月星期一至星期五10时15分0秒</span>
								</div>
							</div>
							<div class="form-group" hidden="">
								<label class="col-sm-3 control-label">计划执行错失触发策略：</label>
								<div class="col-sm-8">
									<label class="radio-inline"> <input type="radio" th:field="*{job.misfirePolicy}" name="misfirePolicy" value="1" /> 立即执行
									</label> <label class="radio-inline"> <input type="radio" th:field="*{job.misfirePolicy}" name="misfirePolicy" value="2" /> 执行一次
									</label> <label class="radio-inline"> <input type="radio" th:field="*{job.misfirePolicy}" name="misfirePolicy" value="3" /> 放弃执行
									</label>
								</div>
							</div>
							<div class="form-group" hidden="">
								<label class="col-sm-3 control-label">状态：</label>
								<div class="col-sm-8">
									<label class="radio-inline"> <input readonly="readonly" th:field="*{job.status}" type="radio" name="status" value="1" />
										运行中
									</label> <label class="radio-inline"> <input readonly="readonly" th:field="*{job.status}" type="radio" name="status" value="0" />未运行
									</label>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">备注信息：</label>
								<div class="col-sm-8">
									<input id="remark" name="remark" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<div class="col-sm-8 col-sm-offset-3">
									<button type="submit" class="btn btn-primary">提交</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div th:replace="footer :: footer"></div>
	<script type="text/javascript">
		var prefix = ctx + "sys/job";
        $().ready(function() {
	        validateRule();
        });
        $.validator.setDefaults({
	        submitHandler : function() {
		        update();
	        }
        });

        function update() {
	        yimo.ajaxPut({
	            url : prefix + "/update",
	            data : $('#JobForm').serialize(),
	            needClose : true,
	            parentRefresh : true,
	        });
        }

        function validateRule() {
	        var icon = "<i class='fa fa-times-circle'></i> ";
	        $("#JobForm").validate({
	            rules : {
	                jobName : {
		                required : true
	                },
	                jobGroup : {
		                required : true
	                },
	                jobClassName : {
		                required : true
	                },
	                cronExpression : {
	                    required : true,
	                    remote : {
	                        url : prefix + "/checkCronExpressionIsValid", // 后台处理程序
	                        type : "get", // 数据发送方式
	                        dataType : "json", // 接受数据格式
	                        data : { // 要传递的数据
		                        cronExpression : function() {
			                        return $("#cronExpression").val();
		                        }
	                        },
	                        dataFilter : function(data, type) {
		                        data = $.parseJSON(data);
		                        $('#cronDesc').attr("value", data.msg);
		                        $("#cronDesc").parents(".form-group").show();
		                        return data.success;
	                        }
	                    }
	                },
	                misfirePolicy : {
		                required : true
	                },
	                status : {
		                required : true
	                },
	            },
	            messages : {
	                jobName : {
		                required : icon + "请输入任务名称"
	                },
	                jobGroup : {
		                required : icon + "请输入任务组名"
	                },
	                jobClassName : {
		                required : icon + "请输入任务方法"
	                },
	                methodParams : {
		                required : icon + "请输入方法参数"
	                },
	                cronExpression : {
	                    required : icon + "请输入cron执行表达式",
	                    remote : icon + "请输入正确的执行表达式"
	                },
	                misfirePolicy : {
		                required : icon + "请输入计划执行策略"
	                },
	            }
	        })
        }
	</script>
</body>
</html>
